<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!-- 在线支付宝扫码页面 -->
<style>
	 .hide{display:none;}
        body {
            padding: 0;
            background-color: #eeeeee;
            font-family: "microsoft yahei";
        }
        
        #not_alipay{
        	background: #f7f7f7;
		    height: 100%;
		    max-width: 640px;
		    min-width: 300px;
		    min-height: 100%;
		    margin: 0 auto;
        }

        .pay-main {
            background-color: #1E9FFF;
            padding-top: 20px;
            padding-left: 20px;
            padding-bottom: 20px;
        }

        .pay-main img {
            margin: 0 auto;
            display: block;
        }

        .pay-main .lines {
            margin: 0 auto;
            text-align: center;
            color: #54ff00;
            font-size: 12pt;
            margin-top: 10px;
        }

        .tips .img {
            margin: 20px;
        }

        .tips .img img {
            width: 20px;
        }

        .tips span {
            vertical-align: top;
            color: #1e9fff;
            padding-left: 10px;
            padding-top: 0px;
        }

        .action {
            background: #1D81D1;
            padding: 10px 0;
            color: #ffffff;
            text-align: center;
            font-size: 14pt;
            border-radius: 10px 10px;
            margin: 15px;
        }

        .action:focus {
            background: #4cb131;
        }

        .action.disabled {
            background-color: #aeaeae;
        }

        .footer {
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            text-align: center;
            padding-bottom: 20px;
            font-size: 10pt;
            color: #aeaeae;
        }

        .footer .ct-if {
            margin-top: 6px;
            font-size: 8pt;
        }

        .jieguo {
            top: 20px;
            line-height: 26px;
            max-width: 260px;
            padding: 8px 20px;
            margin: 0 auto;
            position: relative;
            border: 1px #ddd dashed;
            box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.2);
        }

        .text {
            font-size: 16px;
            font-weight: bold;
            color: #179cff;
        }
        .tip.b{text-align:center;color:#666;}

        .iospayweixinbtn{width:80%;margin:0 auto;padding-top:20px;font-size: 15px;line-height:30px;}
        .time-item strong{font-size:18px;line-height:30px;}

		.mod-title {
		    height: 60px;
		    line-height: 60px;
		    text-align: center;
		    border-bottom: 1px solid #ddd;
		    background: #fff
		}
		
		h1 {
		    font-family: "微软雅黑";
		    font-size: 15px;
		    margin: 5px 0;
		    padding-bottom: 2px;
		    letter-spacing: 2px;
		}
		
		.ico_ALIPAY, .ico_ALI_SOLID {
		    background: url(/img/wx.png) no-repeat;
		    background-size: cover;
		}
		.ico_log {
		    display: inline-block;
		    width: 130px;
		    height: 38px;
		    vertical-align: middle;
		    margin-right: 7px;
		}
		
		.mod-ct {
		    min-width: 300px;
		    max-width: 640px;
		    margin: 0 auto;
		    margin-top: 15px;
		    margin-bottom: 15px;
		    padding-bottom: 10px;
		    background: #fff url(/img/pay/wave.png) top center repeat-x;
		    text-align: center;
		    color: #333;
		    border: 1px solid #e5e5e5;
		    border-top: none;
		}

.onlineAlipay {
	background-color: #f7f7f7 !important	;
}

.mod-ct .amount {
    font-size: 40px;
    padding: 15px 0;
}
.mod-ct .amount {
    font-size: 42px;
}

.mod-ct .amount span{
	font-size: 42px;
}

#alipay_active_btn {
    margin: 10px 0;
    font-size: 30px;
}

#alipay_active_btn {
    margin: 10px 0;
    font-size: 30px;
}

#show_img_wrap img:last-child {
    width: 150px;
    margin: 0 auto;
}

.time-item strong {
    font-size: 18px;
    line-height: 30px;
}

.time-item strong {
    background: #3ec742;
    color: #fff;
    line-height: 25px;
    font-size: 15px;
    font-family: Arial;
    padding: 0 10px;
    margin-right: 10px;
    border-radius: 5px;
    box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.2);
}

.iospayweixinbtn {
    width: 80%;
    margin: 0 auto;
    padding-top: 20px;
    font-size: 15px;
    line-height: 30px;
}

.iospayweixinbtn {
    width: 80%;
    margin: 0 auto;
    padding-top: 20px;
    font-size: 15px;
    line-height: 30px;
}

.glyphicon.glyphicon-chevron-left {
    float: left;
    line-height: 60px;
}
</style>
<section  data-v-16d172c6="" class="main-content onlineAlipay view">
	<div class="conainer">
		    <div id="in_alipay" class="hide">
		        <div class="pay-main">
		            <img src="/img/pay/pay_logo.png">
		            <div class="lines"><span id="tips">支付收银台</span></div>
		        </div>
		        <div class="tips">0div>
		        </div>
		
		        <div id="jieguo" class="jieguo">
		             订单：<span style="color:#008bf3">711918099999190318</span>
		            <br>金额：<font color="#ff0000">5000.00</font>
		            <br>状态：<span id="payzt"><font color="#969494">未支付</font></span>
		        </div>
		        <br><br>
		        <div id="okpay" class="action disabled">正在生成支付,请稍后(14)...</div>
		        <div class="tip b"></div>
		    </div>
		
		    
		    <div id="not_alipay">
		        <h1 class="mod-title">
		            <span class="ico_log ico_ALIPAY"></span>
		        </h1>
		
		        <div class="mod-ct">
		            <div class="amount">￥<span></span></div>
		            <div class="time-item btn_g">
		                <p><a onclick="mShare()" id="btn_share" class="hide">步骤1：点我选择在<b>浏览器</b>中打开<b>授权</b></a></p>
		                <p><a id="alipay_active_btn" class="hide">步骤2：我已完成<b>步骤1</b>，<b>点击此处支付</b></a></p>
		            </div>
		
		            <div class="qrcode-img-wrapper" style="padding-top:20px;">
		                <div class="time-item" id="show_img_wrap" style="text-align:center;">
		                    <img id="show_qrcode" src="http://wb02.28jo.cn/pay/api/temp_file/image/code_page/20190318/1783ef918811190b9552d28edba0b9e9.jpg">
		                </div>
		                <div class="time-item" style="padding:10px 0;text-align:center;">
		                    <strong id="hour_show"><s id="h"></s>0时</strong>
		                    <strong id="minute_show"><s></s>09分</strong>
		                    <strong id="second_show"><s></s>30秒</strong>
		                </div>
		                <div class="iospayweixinbtn"></div>
		            </div>
		            <div class="time-item" style="padding:20px 0;text-align:center;">
		                <div id="msg1"><h1></h1></div>
		                <div><h1 style="color:#cc5005">付款即时到账 未到账可联系我们</h1></div>
		                <div class="orders"><h1>订单:711918099999190318</h1></div>
		            </div>
		        </div>
		    </div>
		</div>
</section>
<script type="text/javascript">
var code_img_url=localStorage.getItem("code_img_url");
var code_link=localStorage.getItem("code_link");
var payMoney=localStorage.getItem("money_real");
var order_no=localStorage.getItem("order_no");
$(".amount span").text(Number(payMoney)/100);
$(".orders h1").text("订单:"+order_no);
$("#show_qrcode").attr("src",code_img_url);
function getCodeParam(name){
	var reg = new RegExp("(^|&)"+name+"=([^&]*)(&|$)","i"); 
	var r =  code_link.substr(1).match(reg);
	var strValue = "";
	if (r!=null){
	 strValue= unescape(r[2]);
	}
	return strValue;
};
var istype=getCodeParam("code_type");
var pay_way=getCodeParam("pc"); /* 拉起支付的客户端：1=PC 2=Android 3=Ios*/
var href=window.location.href;
var durl=/https?:\/\/([^\/]+)\//i; 
var domain = href.match(durl); 
/* var return_url = domain[0]+"pay/payReturnTwo.do"; */


var qry = {__id:''};
var ali_order_no='';
var is_paying= "0";
var time=parseInt(new Date().getTime() / 1000);
var lastTime = String(time+600);
var tpl_url="http://api.28jo.cn/pay/api/tpl/pay_page";
var http_host="http://api.28jo.cn/pay/api";
var myTimer,is_mobile=isMobile(),is_weixin=isWeixin(),isAlipay=isAlipay(),is_time_out=0; 
var isiOS = !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);

/* isAlipay=1;*/

qry.listener = function(){
	if($(".onlineAlipay").length==1){
		 $.getJSON(http_host+'/api.php?action=pay_page&m=check_pay',{order_no:order_no},function(data){
            qry.showResult(data);
        });
	}
};

qry.showResult = function( data ){
    if (data.is_pay == "1") {
        qry.pay_success(data);
    }else if(data.is_pay == "0"){
        if(!is_time_out){
            setTimeout(function () { qry.listener() }, 2000); 
        }
    }
};

qry.pay_success= function(){
	$.ajax({
        url:"/pay/findPaymentResult.do",
        type: "post",
        data: {"order_no":order_no},
        success: function (data) {   
        }
    });
    if(isAlipay){
        $("#payzt font").html("支付成功");
        $("#okpay").addClass("hide");
    }else{
        qry.resetTime();
        $("#show_img_wrap canvas,#show_img_wrap canvas + img").hide();
        $('#show_qrcode').removeClass("hide").attr('src',tpl_url+'/images/success.jpg');
        $('#msg1').html('<h1 style="color:red;font-size:35px;font-weight:normal">订单支付成功！</h1>');
		
        /*  if (is_mobile == 1) {
            if(return_url){
                $('#alipay_active_btn').attr("href",return_url).html("返回商家页");
            }else{
                $('#alipay_active_btn').attr("href","javascript:history.go(-1)").html("返回上一页");
            }
        } else {
           if(return_url){
                $('#msg1').html('<h1>支付成功，即将跳转到<a style="font-weight:bold;" href="'+return_url+'">商家</a>页面</h1>');
                setTimeout(function () { window.location = return_url }, 3000);
            } 
        }*/
    } 
};

qry.disabled = function(){
    if(isAlipay){
        $("#payzt font").html("过期未支付！");
        $("#okpay").addClass("hide");         
    }else{
        $("#btn_share").addClass("hide");
        $('#show_qrcode').removeClass("hide").attr('src',tpl_url+'/images/qrcode_timeout.png');
        $("#show_img_wrap canvas,#show_img_wrap canvas + img").hide();
        $('#msg1').html('<h1>过期未支付！</h1>');
        clearInterval(myTimer);

        if(is_mobile == 1){
            $('#alipay_active_btn').attr("href","javascript:history.go(-1)").html('返回上一页');
        }
    }
};
qry.resetTime = function() {
    clearInterval(myTimer);
    var hour   = 0;
    var minute = 0;
    var second = 0;
    $('#hour_show').html('<s id="h"></s>' + hour + '时');
    $('#minute_show').html('<s></s>' + minute + '分');
    $('#second_show').html('<s></s>' + second + '秒');
};

qry.showTime = function() {
    myTimer = window.setInterval(function () {
        var intDiff = lastTime - parseInt(new Date().getTime() / 1000);
        
        day = Math.floor(intDiff / (60 * 60 * 24));
        hour = Math.floor(intDiff / (60 * 60)) - (day * 24);
        minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
        second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);

        if (minute <= 9) minute = '0' + minute;
        if (second <= 9) second = '0' + second;
        $('#hour_show').html('<s id="h"></s>' + hour + '时');
        $('#minute_show').html('<s></s>' + minute + '分');
        $('#second_show').html('<s></s>' + second + '秒');
        if (hour <= 0 && minute <= 0 && second <= 0) {
            is_time_out=1;
            qry.disabled();
        }
    }, 1000);
};

var btn = document.getElementById('okpay');
var re = 0;
var d = ["..", "...", "...."];
var i = 1;
var desc = 30;
var t = setInterval(function () {
if (re == 0) {
    if (i % 2 == 1)
        desc--;
    btn.innerText = "正在生成支付,请稍后(" + desc + ")" + d[(i++ % 3)];
    if (desc == 0) {
        re = 2;
        btn.innerText = "生成超时,请重新下单";
        clearInterval(t);
        $(".tip.b").html("若不能拉起支付，请关闭支付宝后重新扫码进入本页面");
    }
}
}, 1000);

$(function(){
/* 设置显示样式 */
if(is_mobile=='1'){
   if(is_weixin==1){
       
   }else if(is_weixin==0){
        if(istype==1){ /* 其他手机浏览器+微信支付 */
            
        }else if(istype==2){ /* 其他手机浏览器+支付宝支付 */
            if(!isAlipay){
                var scan_tip="温馨提示 请按下面步骤：<br><span class='red'>1、请先截屏保存二维码到手机</span><br><span class='red'>2、打开支付宝App 扫一扫本地图片。</span>";
                $(".iospayweixinbtn").html(scan_tip);
            }

            if(!isAlipay){
            }else{
               $("#not_alipay").addClass("hide");
               $("#in_alipay").removeClass("hide");
            }
        }
   }
}

if(is_paying==0){
    qry.showTime(); /*开始付款倒计时;*/
    if (is_mobile == 1) {
        pay_way=2;
        if(isiOS)pay_way=3;
    }
    if(!isAlipay){/* 移动端先跳到支付宝内部 */
       /*   var code_link_pre="alipays://platformapi/startapp?appId=20000067&url=";
         var mobile_pay_link='http://api.28jo.cn/pay/api/api.php?action=pay_page&m=code_page_code&order_no=711918099999190318&code_type=2';
        mobile_pay_link=code_link_pre+encodeURIComponent(mobile_pay_link);
         window.location.href=mobile_pay_link; */
    }else{
        if(!ali_order_no){
            addFirends();
        } 
        get_ali_order_no();           
    }

    /* record_pay_source(pay_way); */
    qry.listener();
}else if(is_paying==1){
     qry.pay_success();
}else if(is_paying==2){
    qry.disabled();
}
});


function get_ali_order_no(){
	$.getJSON(http_host+'/api.php?action=pay_page&m=get_ali_order_no',{order_no:order_no},function(data){
	    if(data.code==0){
	        ali_order_no=data.data.ali_order_no;
	        $("#okpay").removeClass("disabled").attr("onclick","jumpPay()");
	        jumpPay();
	    }else{
	        if(!is_time_out){
	            setTimeout(function () { get_ali_order_no() }, 500); 
	        }
	    }
	});
};

function addFirends() {
	var action ='alipays://platformapi/startapp?appId=20000186&actionType=addfriend&source=by_home&userId=2088332546664201&loginId=17827486931';
	AlipayJSBridge.call('pushWindow', { url: action });
};
function jumpPay() {
/* window.location.href = 'alipays://platformapi/startapp?appId=20000003&actionType=toBillDetails&tradeNO='+ali_order_no; */
window.location.href='https://render.alipay.com/p/s/i?scheme=alipays%3A%2F%2Fplatformapi%2Fstartapp%3FsaId%3D10000007%26qrcode%3D' +
                    encodeURIComponent ('https://66666676.h5app.alipay.com/www/index.html?tradeNo=' + ali_order_no);
};



/* 记录拉起支付的客户端：1=PC 2=Android 3=Ios */
function record_pay_source(pay_way){ 
	$.ajax({
	    url: http_host+"/api.php?action=pay_page&m=record_pay_way",
	    asyn:true,
	    type: "post",
	    data: {"order_no":order_no,"pay_way":pay_way},
	    dataType: "json",
	    success: function (data) {   
	        if (data) { 
	        }
	    }
	});
}


function isWeixin() {
	var ua = window.navigator.userAgent.toLowerCase();
	if (ua.match(/MicroMessenger/i) == 'micromessenger') {
	    return 1;
	} else {
	    return 0;
	}
}

function isAlipay() {
	var ua = window.navigator.userAgent.toLowerCase();
	if (ua.match(/Alipay/i) == "alipay") {
	    return 1;
	} else {
	    return 0;
	}
}


function isMobile() {
	var ua = navigator.userAgent.toLowerCase();
	_long_matches = 'googlebot-mobile|android|avantgo|blackberry|blazer|elaine|hiptop|ip(hone|od)|kindle|midp|mmp|mobile|o2|opera mini|palm( os)?|pda|plucker|pocket|psp|smartphone|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce; (iemobile|ppc)|xiino|maemo|fennec';
	_long_matches = new RegExp(_long_matches);
	_short_matches = '1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-';
	_short_matches = new RegExp(_short_matches);
	if (_long_matches.test(ua)) {
	    return 1;
	}
	user_agent = ua.substring(0, 4);
	if (_short_matches.test(user_agent)) {
	    return 1;
	}
	return 0;
}

/*获得url上指定参数的值 */
function get_query_string(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)","i");
	var r = window.location.search.substr(1).match(reg);
	if (r != null) return decodeURI(r[2]); return null;
}
</script>
